<?php
 
/**
 * Calls the render() method of the Extend view helper if needed
 *
 * @author Mon Zafra <monzee at gmail>
 * @copyright (c)2009 Mon Zafra
 * @category Mz
 * @package
 * @license http://mz-project.googlecode.com/svn/trunk/LICENSE MIT License
 * @version SVN: $Id: Extend.php 52 2009-11-28 04:07:02Z monzee@gmail.com $
 */
class Zend_View_Filter_Extend
{
    public $view;
 
    /**
     * Receive a reference of the view upon instantiation.
     *
     * @param Zend_View_Interface$view
     */
    public function setView($view)
    {
        $this->view = $view;
    }
 
    /**
     * Renders the master view if needed.
     *
     * @param string $buffer
     * @return string
     */
    public function filter($buffer)
    {
        $helper = $this->view->getHelper('extend');
        if ($helper->isOpen()) {
            $helper->setCurrentSection($buffer);
            $buffer = $helper->render();
        }
        return $buffer;
    }
 
}
